package com.lh.controller;

import com.lh.domian.ResponseResults;
import com.lh.service.ArticleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author LuoHang
 * @Date 2022-08-25 21:57
 **/
@RestController
@RequestMapping("/article")
public class ArticleController {
    @Resource
    private ArticleService articleService;

    @GetMapping("/hotArticleList")
    public ResponseResults hotArticleList(){
        return articleService.hotArticleList();
    }

    @GetMapping("/articleList")
    public ResponseResults articleList(@RequestParam(name = "categoryId",required = false) Long categoryId,
                                       Integer pageNum,Integer pageSize){
        return articleService.articleList(categoryId,pageNum,pageSize);
    }

    @GetMapping("/{id}")
    public ResponseResults getArticleDetail(@PathVariable("id") Long id){
        return articleService.getArticleDetail(id);
    }

    @PutMapping("/updateViewCount/{id}")
    public ResponseResults updateViewCount(@PathVariable("id") Long id){
        return articleService.updateViewCount(id);
    }
}
